package com.java.control.search;

import java.util.Date;

import org.apache.commons.lang.StringUtils;

/**
 * 样品
 * @author wqf
 * @version  Nov 24, 2011 11:55:45 AM
 */
public class SendSearchCond extends SearchCond{
	
	private String expressCompany;
	
	private String expressNumber;
	/**
	 * 开始时间
	 */
	private Date beginDate;
	
	/**
	 * 结束时间
	 */
	private Date endDate;
	
	private String country;
	
	private Long userId;
	
	private Long expressCompanyId;
	private Boolean paymentMethod;
	
	public Boolean getPaymentMethod() {
		return paymentMethod;
	}

	public void setPaymentMethod(Boolean paymentMethod) {
		this.paymentMethod = paymentMethod;
	}

	public ConditionPart getCondition(){
		ConditionPart cp=new ConditionPart();
		StringBuffer searchStr=new StringBuffer(" 1=1");
		
		if(StringUtils.isNotBlank(expressCompany)){
			searchStr.append(" and expressCompany.codeName=?");
			cp.getParams().add(expressCompany);
		}
		if(StringUtils.isNotBlank(expressNumber)){
			searchStr.append(" and expressNumber=?");
			cp.getParams().add(expressNumber);
		}
		if (this.beginDate != null){
			searchStr.append(" and sendDate=?");
			cp.getParams().add(this.beginDate);
		}
		if (this.endDate != null){
			searchStr.append(" and sendDate<=?)");
			cp.getParams().add(this.endDate);
		}
		if(StringUtils.isNotBlank(this.country)){
			searchStr.append(" and country=?");
			cp.getParams().add(country);
		}
		if(this.userId!=null){
			searchStr.append(" and user.id=?");
			cp.getParams().add(userId);
		}
		if(this.expressCompanyId!=null){
			searchStr.append(" and expressCompany.id=?");
			cp.getParams().add(expressCompanyId);
		}
		if(this.paymentMethod!=null){
			searchStr.append(" and paymentMethod=?");
			cp.getParams().add(paymentMethod);
		}
		cp.setExpression(searchStr.toString());
		return cp;
	}

	public String getExpressNumber() {
		return expressNumber;
	}

	public void setExpressNumber(String expressNumber) {
		this.expressNumber = expressNumber;
	}
	public String getExpressCompany() {
		return expressCompany;
	}

	public Long getExpressCompanyId() {
		return expressCompanyId;
	}

	public void setExpressCompanyId(Long expressCompanyId) {
		this.expressCompanyId = expressCompanyId;
	}

	public void setExpressCompany(String expressCompany) {
		this.expressCompany = expressCompany;
	}

	public String getCountry() {
		return country;
	}

	public void setCountry(String country) {
		this.country = country;
	}

	public Long getUserId() {
		return userId;
	}

	public void setUserId(Long userId) {
		this.userId = userId;
	}

	public Date getBeginDate() {
		return beginDate;
	}

	public void setBeginDate(Date beginDate) {
		this.beginDate = beginDate;
	}

	public Date getEndDate() {
		return endDate;
	}

	public void setEndDate(Date endDate) {
		this.endDate = endDate;
	}
}
